<template>
	<view class="body">
		<xk-header title="统计"></xk-header>
		<view class="header-card">
			<view class="item">
				<view class="left-img">
					<image :src="(imgUrl+'/wx/jingGao.png')" style="width: 60rpx;" mode="widthFix"></image>
				</view>
				<view class="right-num">
					本月警告总数<br />
					<text class="num">{{warnAll || 0}}</text>次
				</view>
			</view>
			<view class="item item-2">
				<view class="left-img">
					<image :src="(imgUrl+'/wx/lianwang@3x.png')" style="width: 60rpx;" mode="widthFix"></image>
				</view>
				<view class="right-num">
					联网设备总数<br />
					<text class="num">{{equInternetAll || 0}}</text>个
				</view>
			</view>
			<view class="item item-3">
				<view class="left-img">
					<image :src="(imgUrl+'/wx/renyuan@3x.png')" style="width: 60rpx;" mode="widthFix"></image>
				</view>
				<view class="right-num">
					人员总数<br />
					<text class="num">{{personAll || 0}}</text>人
				</view>
			</view>
			<!-- <view class="item item-4">
				<view class="left-img">
					<image :src="(imgUrl+'/wx/chewei@3x.png')" style="width: 60rpx;" mode="widthFix"></image>
				</view>
				<view class="right-num">
					车位总数<br />
					<text class="num">{{cheweiNum}}</text>个
				</view>
			</view> -->
		</view>
		<view class="device-title">
			设备统计
		</view>
		<view class="device-content">
			<device-pie :allInternet="equInternetAll"></device-pie>
		</view>
		<!-- <view class="device-content">
			<big-device></big-device>
		</view>
		<view class="device-title">
			便捷通行
		</view>
		<view class="device-content">
			<travel @getChewwei="setChe"></travel>
		</view>
		<view class="device-title">
			能耗统计
		</view>
		<view class="device-content">
			<consume></consume>
		</view>
		<view class="device-title">
			告警统计
		</view>
		<view class="device-content">
			<warn></warn>
		</view> -->
	</view>
</template>

<script>
	import moment from 'moment'
	import devicePie from './device-pie.vue'
	// import bigDevice from './big-device.vue'
	// import travel from './travel.vue'
	// import consume from './consume.vue'
	// import warn from './warn.vue'
	export default {
		components: {
			'device-pie': devicePie,
			// 'big-device': bigDevice,
			// 'travel': travel,
			// 'consume': consume,
			// 'warn': warn,
		},
		data() {
			return {
				imgUrl:this.$config.BASE_imgUrl,
				lianwangNum: 0,
				cheweiNum: 0,
				warnAll:0,
				personAll :0,
				equInternetAll:0
			}
		},
		mounted() {
			let that = this
			//告警总次数
			uni.request({
				url:'https://ibms.on-bright.com:8000/msg/cockpit/queryALarmCount',
				method: 'POST',
				header: {
				     'Content-Type': 'application/json' // 请求头设置为json格式
				   },
				   success: function(res) {
					   console.log('请求成功的回调函数',res);
					   that.warnAll = res.data.data
				     // console.log(res.data); // 请求成功的回调函数，输出响应数据
				   },
				   fail: function(err) {
				     console.log(err); // 请求失败的回调函数，输出错误信息
				   }
			})
			// 人员数量
			uni.request({
				url:'https://ibms.on-bright.com:8000/msg/cockpit/queryPersonCount',
				method: 'POST',
				header: {
				     'Content-Type': 'application/json' // 请求头设置为json格式
				   },
				   success: function(res) {
					   that.personAll = res.data.data
				     // console.log(res.data); // 请求成功的回调函数，输出响应数据
				   },
				   fail: function(err) {
				     console.log(err); // 请求失败的回调函数，输出错误信息
				   }
			})
			// 联网设备数量
			uni.request({
				url:'https://ibms.on-bright.com:8000/msg/cockpit/queryDevOnlineCount',
				method: 'POST',
				header: {
				     'Content-Type': 'application/json' // 请求头设置为json格式
				   },
				   success: function(res) {
					   that.equInternetAll = res.data.data
				     console.log(res.data.data); // 请求成功的回调函数，输出响应数据
				   },
				   fail: function(err) {
				     console.log(err); // 请求失败的回调函数，输出错误信息
				   }
			})

			// this.getData3();
			// this.getData4();
		},
		methods:{
			setLian(data){
				this.lianwangNum = data;
			},
			setChe(data){
				this.cheweiNum = data;
			},
			getData3(){
				this.$util.get({
					url: 'statAlarmLevelAndDeal',
					deviceCtrl: 10
				}).then(res=>{
					console.log(res)
				})
			},
			getData4(){
				this.$util.get({
					url: 'statFromEnvSys',
					deviceCtrl: 10
				}).then(res=>{
					console.log(res)
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.header-card {
		padding: 20rpx 20rpx 0;
		background: #FFFFFF;
		display: flex;
		justify-content: space-between;
		flex-wrap: wrap;

		.item {
			width: 316rpx;
			height: 140rpx;
			padding: 15rpx;
			display: flex;
			background: #FFE5E5;
			border-radius: 20rpx;
			margin-bottom: 20rpx;
			.left-img {
				padding-top: 20rpx;
			}

			.right-num {
				line-height: 70rpx;
				width: 80%;
				flex: 1;
				margin-left: 20rpx;
				font-size: 28rpx;
				color: #333333;
				font-weight: 400;
				.num{
					font-size: 32rpx;
					font-weight: bold;
					color: #FF3737;
				}
			}
			&.item-2{
				background: #E5EFFF;
				.num{
					color: #2C72FF;
				}
			}
			&.item-3{
				background: #E5FFF1;
				.num{
					color: #46D79D;
				}
			}
			&.item-4{
				background: #FFF3E5;
				.num{
					color: #FF972C;
				}
			}
		}
	}
	.device-title{
		height: 80rpx;
		line-height: 80rpx;
		padding: 0 20rpx;
		font-size: 32rpx;
		color: #333333;
		font-weight: 600;
	}
	.device-content{
		// height: 520rpx;
		// width: 100%;
		padding: 0 20rpx;
		&:last-child{
			padding-bottom: 30rpx;
		}
	}
</style>
